<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>Leaflet debug page - Popup Context Menu Clicks</title>
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
		<link rel="stylesheet" href="../../dist/leaflet.css" />
		<link rel="stylesheet" href="../css/screen.css" />
		<script type="importmap">
			{
				"imports": {
					"leaflet": "../../dist/leaflet-src.esm.js"
				}
			}
		</script>
	</head>
	<body>
		<div id="map"></div>
		<button id="populate">Populate with 10 markers</button>
		<script type="module">
			import {Map, TileLayer, GeoJSON, Marker} from 'leaflet';

			const map = new Map('map').setView([36.9, -95.4], 5);

			map.on('contextmenu', () => {
				alert('The map has been right-clicked');
			});

			new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);

			const exampleGeoJSON = {
				type: 'Polygon',
				coordinates: [
					[
						[-90.0, 35.0],
						[-90.0, 45.0],
						[-100.0, 45.0],
						[-100.0, 35.0],
					],
				],
			};

			new GeoJSON(exampleGeoJSON, {
				onEachFeature(feature, layer) {
					layer.on('contextmenu', () => {
						alert('The GeoJSON layer has been clicked');
					});
				},
			}).addTo(map);

			const marker = new Marker([36, -95]).addTo(map);
			marker
				.bindPopup('Right-click me <br> to test contextmenu <br> event capture')
				.openPopup();
		</script>
	</body>
</html>
